#ifndef M0WIG_H
#define M0WIG_H

#include <QWidget>
#include <QUdpSocket>
#include <QThread>
#include <QTimer>
#include <QTcpSocket>
#include <QJsonObject>
#include <QJsonDocument>
#include <QFile>
#include <QThread>
#include "mythread.h"
#include <QtEndian>
namespace Ui {
class M0Wig;
}

class M0Wig : public QWidget
{
    Q_OBJECT

public:
    explicit M0Wig(QWidget *parent = 0);
    ~M0Wig();

    void periodicTask();
    void JSONDecSend();
    void fileServe();
signals:

private slots:
    void on_search_pushButton_clicked();
    void readPendingDatagrams();
    void TcpReadSlot();
    void onDelayTimeout();
    void on_pushButton_2_clicked();

private:
    Ui::M0Wig *ui;
    QUdpSocket *udpServer;
    QTcpSocket *tcpClient;
    QByteArray datagram;
    QTimer *delayTimer;
    QByteArray receiveBuffer;
    QHostAddress sender;
    quint16 senderPort;

    int reccount=0;
    int connectionAttempts = 0;
    int maxAttempts = 10;
};

#endif // M0WIG_H
